home *** CD-ROM | disk | FTP | other *** search
/ Micromanía 90 / CDMM_90_1.ISO / Cycling Manager 2 / CyclingManager2Demo.exe / Disk1 / data1.cab / Game / DataCM2 / scripts / elements / buttons.cnh < prev    next >
Encoding:
Text File  |  2002-05-10  |  47.2 KB  |  1,835 lines

  1. // buttons.cnh
  2.  
  3. // -------------------------------------------------------------
  4. // Constructors
  5. // -------------------------------------------------------------
  6. // Init func Predeclaration
  7. func Gui_Component NewButton(Menu_Material _pMaterial);
  8. func Gui_Component NewButton_Size(Menu_Material _pMaterial,f32x _sx,f32x _sy);
  9. func Gui_Component NewButton_Text(Menu_Material _pFont,szx _sxTxt,f32x _sx,f32x _sy);
  10. func Gui_Component NewButton_CenterText(Menu_Material _pMaterial,Menu_Material _pFont,szx _sxTxt);
  11. func Gui_Component NewButton3D(Menu_Mesh _pMesh);
  12. func Gui_Component NewButton_FrameText(Menu_Material _pMaterialRight, Menu_Material _pMaterialCenter, Menu_Material _pMaterialLeft,Menu_Material _pFont,szx _sxTxt);
  13. func Gui_Component NewButton_FrameTextWithHelp(Menu_Material _pMaterialRight, Menu_Material _pMaterialCenter, Menu_Material _pMaterialLeft, Menu_Material _pFont,szx _sxTxt);
  14. func Gui_Component NewButtonDyn(Menu_Material _pMaterial);
  15.  
  16. func Gui_Component NewCheckbox(Menu_Material _pMaterial);
  17. func Gui_Component NewCheckbox_Text(Menu_Material _pMaterial,Menu_Material _pFont,szx _szTxt);
  18. func i32x Checkbox_bIsChecked(Gui_Component _pCheckbox);
  19.  
  20. func Gui_Component NewRadioButton(Menu_Material _pMaterial,i32x _iValue);
  21. func Gui_Component NewRadioButton_Text(Menu_Material _pMaterial,Menu_Material _pFont,szx _szTxt,i32x _iValue);
  22. func Gui_Component NewRadioButton_CenterText(Menu_Material _pMaterial,Menu_Material _pFont,szx _sxTxt,i32x _iValue);
  23. func Gui_Component NewRadioButton_CenterTextExt(Menu_Material _pMaterial,Menu_Material _pFont,szx _sxTxt,i32x _iValue,i32x _iWidth,i32x _iHeight);
  24. func Gui_Component NewTextRadioButton(Menu_Material _pFont,szx _szTxt,i32x _iValue);
  25.  
  26. // CM2 graphic chart implementation
  27. func Gui_Component NewCM2Button(szx _sxTxt);
  28.  
  29. func Gui_Component NewCM2InRaceButton1(szx _sxTxt);
  30. func Gui_Component NewCM2InRaceButton2(szx _sxTxt);
  31. func Gui_Component NewCM2InRaceButton(szx _sxTxt, szx _sxTxt2, szx _szContextualCaption);
  32.  
  33. func Gui_Component NewCM2BmpButton(Menu_Material _pMaterial, i32x _iIndex, i32x _iOffset, szx _szContextualCaption);
  34. // end of CM2 graphic chart
  35.  
  36.  
  37.  
  38.  
  39. // Needed for contextual help
  40. var Gui_Component g_cCurrentHelpComponent;
  41.  
  42. // Standard buttons
  43. // Data class
  44. class Gui_dtCheckbox
  45. {
  46.     var boolx bChecked;
  47. };
  48. class Gui_dtRadioButton
  49. {
  50.     var i32x iValue;
  51.     var boolx bChecked;
  52. };
  53. class Gui_dtRadioButtonComposite
  54. {
  55.     var Gui_Component gcRadioButton;
  56.     var Gui_Component gcCaption;
  57. };
  58. class Gui_dtFrameTextButton
  59. {
  60.     var Gui_Component gcRightButton;
  61.     var Gui_Component gcCenterButton;
  62.     var Gui_Component gcLeftButton;
  63.     var Gui_Component gcText;
  64. };
  65. class Gui_dtCM2InRaceButton
  66. {
  67.     var Gui_Component gcRightButton;
  68.     var Gui_Component gcCenterButton;
  69.     var Gui_Component gcLeftButton;
  70.     var Gui_Component gcText;
  71.     var boolx bChecked;
  72.     var szx szContextualCaption;
  73. };
  74. class Gui_dtCM2BmpButton
  75. {
  76.     var i32x iIndex;
  77.     var i32x iOffset;
  78.     var boolx bChecked;
  79.     var szx szContextualCaption;
  80. };
  81.  
  82. // Message
  83. message ClickDown(Gui_Component _pComponent);
  84. message ClickUp(Gui_Component _pComponent);
  85. message Click(Gui_Component _pComponent);
  86. message RightClick(Gui_Component _pComponent);
  87. message MiddleClick(Gui_Component _pComponent);
  88. message RadioCheck(Gui_Component _pComponent,i32x _iValue);
  89. message Check(Gui_Component _pComponent);
  90. message QuietRadioCheck(i32x _iValue);
  91. message Uncheck(Gui_Component _pComponent);
  92. message QuietCheck();
  93. message QuietUncheck();
  94. message MouseClick(i32x _iX,i32x _iY,i32x _iButton);
  95. message MouseLeave(i32x _iX, i32x _iY);
  96.  
  97. // -------------------------------------------------------------
  98. // -------------------------------------------------------------
  99.  
  100.  
  101. // Predeclaration
  102. func void ButtonComposite_OnClick(Gui_Component _pComponent);
  103. func i32x ButtonComposite_OnMouseEnter(i32x _iX,i32x _iY);
  104. func i32x ButtonComposite_OnMouseLeave(i32x _iX,i32x _iY);
  105. func i32x ButtonComposite_OnMouseDown(i32x _iX,i32x _iY,i32x _iButton);
  106. func i32x ButtonComposite_OnMouseUp(i32x _iX,i32x _iY,i32x _iButton);
  107. func i32x Button_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton);
  108.  
  109. func void HelpButtonComposite_OnClick(Gui_Component _pComponent);
  110. func i32x HelpButtonComposite_OnMouseDown(i32x _iX,i32x _iY,i32x _iButton);
  111. func i32x HelpButtonComposite_OnMouseUp(i32x _iX,i32x _iY,i32x _iButton);
  112.  
  113.  
  114. func i32x ButtonDyn_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton);
  115. func i32x ButtonDyn_OnMouseEnter(i32x _iX,i32x _iY);
  116. func i32x ButtonDyn_OnMouseLeave(i32x _iX,i32x _iY);
  117. func i32x ButtonDyn_OnMouseDown(i32x _iX,i32x _iY,i32x _iButton);
  118. func i32x ButtonDyn_OnMouseUp(i32x _iX,i32x _iY,i32x _iButton);
  119.  
  120. func i32x Checkbox_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton);
  121. func i32x Checkbox_OnQuietCheck();
  122. func i32x Checkbox_OnQuietUncheck();
  123. func i32x Checkbox_OnEnable();
  124. func i32x Checkbox_OnDisable();
  125.  
  126. func i32x RadioButton_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton);
  127. func void RadioButton_OnQuietCheck(i32x _iValue);
  128. func i32x TextRadioButton_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton);
  129. func void TextRadioButton_OnQuietCheck(i32x _iValue);
  130. func void RadioButtonComposite_OnQuietCheck(i32x _iValue);
  131.  
  132.  
  133. func void CM2InRaceButton_OnClick(Gui_Component _pComponent);
  134. func i32x CM2InRaceButton_OnMouseEnter(i32x _iX,i32x _iY);
  135. func i32x CM2InRaceButton_OnMouseLeave(i32x _iX,i32x _iY);
  136. func i32x CM2InRaceButton_OnMouseDown(i32x _iX,i32x _iY,i32x _iButton);
  137. func i32x CM2InRaceButton_OnUncheck(Gui_Component _pSender);
  138. func i32x CM2InRaceButton_OnCaption(szx _sxCaption);
  139.  
  140.  
  141. func void CM2BmpButton_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton);
  142. func i32x CM2BmpButton_OnMouseEnter(i32x _iX,i32x _iY);
  143. func i32x CM2BmpButton_OnMouseLeave(i32x _iX,i32x _iY);
  144. func i32x CM2BmpButton_OnMouseDown(i32x _iX,i32x _iY,i32x _iButton);
  145. func i32x CM2BmpButton_OnUncheck(Gui_Component _pSender);
  146. func i32x CM2BmpButton_OnCheck(Gui_Component _pSender);
  147.  
  148.  
  149. // Message handling interface
  150. interface Gui_iBitmapButtonDyn
  151. {
  152.     ButtonDyn_OnMouseClick MouseClick;
  153.     ButtonDyn_OnMouseDown    MouseDown;
  154.     ButtonDyn_OnMouseEnter    MouseEnter;
  155.     ButtonDyn_OnMouseLeave    MouseLeave;
  156.     ButtonDyn_OnMouseUp        MouseUp;
  157. }
  158. interface Gui_iBitmapButton
  159. {
  160.     Button_OnMouseClick MouseClick;
  161. }
  162. interface Gui_iBitmapCheckbox
  163. {
  164.     Checkbox_OnMouseClick MouseClick;
  165.     Checkbox_OnQuietCheck QuietCheck;
  166.     Checkbox_OnQuietUncheck QuietUncheck;
  167.  
  168.     Checkbox_OnEnable Enable;
  169.     Checkbox_OnDisable Disable;
  170. }
  171. interface Gui_iBitmapRadioButton
  172. {
  173.     RadioButton_OnMouseClick MouseClick;
  174.  
  175.     RadioButton_OnQuietCheck QuietRadioCheck;
  176. }
  177. interface Gui_iTextRadioButton
  178. {
  179.     TextRadioButton_OnMouseClick MouseClick;
  180.  
  181.     TextRadioButton_OnQuietCheck QuietRadioCheck;
  182. }
  183.  
  184. interface Gui_iButtonComposite
  185. {
  186.     ButtonComposite_OnClick            Click;
  187.     ButtonComposite_OnMouseDown        MouseDown;
  188.     ButtonComposite_OnMouseEnter    MouseEnter;
  189.     ButtonComposite_OnMouseLeave    MouseLeave;
  190. }
  191.  
  192. interface Gui_iHelpButtonComposite
  193. {
  194.     HelpButtonComposite_OnClick            Click;
  195.     HelpButtonComposite_OnMouseDown        MouseDown;
  196.     HelpButtonComposite_OnMouseUp MouseUp;
  197. }
  198.  
  199. interface Gui_iCheckbox_Composite
  200. {
  201. }
  202.  
  203. interface Gui_iRadioButton_Composite
  204. {
  205.     RadioButtonComposite_OnQuietCheck QuietRadioCheck;
  206. }
  207.  
  208. interface Gui_iCM2InRaceButton
  209. {
  210.     CM2InRaceButton_OnClick            Click;
  211.     CM2InRaceButton_OnMouseDown        MouseDown;
  212.     CM2InRaceButton_OnMouseEnter    MouseEnter;
  213.     CM2InRaceButton_OnMouseLeave    MouseLeave;
  214.     CM2InRaceButton_OnUncheck        Uncheck;
  215.     CM2InRaceButton_OnCaption        Caption;
  216. }
  217.  
  218. interface Gui_iCM2BmpButton
  219. {
  220.     CM2BmpButton_OnMouseClick    MouseClick;
  221.     CM2BmpButton_OnMouseDown    MouseDown;
  222.     CM2BmpButton_OnMouseEnter    MouseEnter;
  223.     CM2BmpButton_OnMouseLeave    MouseLeave;
  224.     CM2BmpButton_OnUncheck        Uncheck;
  225.     CM2BmpButton_OnCheck        Check;
  226. }
  227.  
  228.  
  229.  
  230. /*
  231.  *    Function        : Button_Init button initializer 
  232.  *    Parameters        : _pMaterial material pointer
  233.  */
  234. func Gui_Component NewButton(Menu_Material _pMaterial)
  235. {
  236.     var Menu_Sprite sprite;
  237.     var Gui_Component container;
  238.     var f32x sx,sy;
  239.     var i32x iArea;
  240.  
  241.     // Create container with button interface
  242.     container = NewContainer(Gui_iBitmapButton);
  243.     CatchEvent(container,e_GUI_Event_Mouse_Move);
  244.  
  245.     // Create a sprite with material and area index e_GUI_State_Enabled
  246.     sprite = NewSprite2D(_pMaterial);
  247.     iArea = e_GUI_State_Enabled;
  248.     SetArea(sprite,iArea);
  249.  
  250.     // Get size of area of index e_GUI_State_Enabled
  251.     sx = GetAreaWidth(_pMaterial,iArea);
  252.     sy = GetAreaHeight(_pMaterial,iArea);
  253.  
  254.     // Strech container to area size
  255.     StretchTo(container,sx,sy);
  256.  
  257.     // Define default align left/top (quicker than zoom)
  258.     SetAlign(container,e_GUI_HAlign_Left,e_GUI_VAlign_Top);
  259.  
  260.     // Attach the sprite to this container
  261.     AttachSprite(container,sprite);
  262.  
  263.     // Tell Gui to clip this sprite to container size
  264.     Clip(container);
  265.  
  266.     return container;
  267. }
  268.  
  269. /*
  270.  *    Function        : NewButtonDyn button dyn initializer 
  271.  *    Parameters        : _pMaterial material pointer
  272.  */
  273. func Gui_Component NewButtonDyn(Menu_Material _pMaterial)
  274. {
  275.     var Menu_Sprite sprite;
  276.     var Gui_Component container;
  277.     var f32x sx,sy;
  278.     var i32x iArea;
  279.  
  280.     // Create container with button interface
  281.     container = NewContainer(Gui_iBitmapButtonDyn);
  282.     CatchEvent(container,e_GUI_Event_Mouse_Move);
  283.  
  284.     // Create a sprite with material and area index e_GUI_State_Enabled
  285.     sprite = NewSprite2D(_pMaterial);
  286.     iArea = e_GUI_State_Enabled;
  287.     SetArea(sprite,iArea);
  288.  
  289.     // Get size of area of index e_GUI_State_Enabled
  290.     sx = GetAreaWidth(_pMaterial,iArea);
  291.     sy = GetAreaHeight(_pMaterial,iArea);
  292.  
  293.     // Strech container to area size
  294.     StretchTo(container,sx,sy);
  295.  
  296.     // Define default align left/top (quicker than zoom)
  297.     SetAlign(container,e_GUI_HAlign_Left,e_GUI_VAlign_Top);
  298.  
  299.     // Attach the sprite to this container
  300.     AttachSprite(container,sprite);
  301.  
  302.     // Tell Gui to clip this sprite to container size
  303.     Clip(container);
  304.  
  305.     return container;
  306. }
  307.  
  308. /*
  309.  *    Function        : Button_Init button initializer 
  310.  *    Parameters        : _pMaterial material pointer
  311.  */
  312. func Gui_Component NewButton3D(Menu_Mesh _pMesh)
  313. {
  314.     var Menu_Sprite sprite;
  315.     var Gui_Component container;
  316.     var f32x sx,sy,s;
  317.  
  318.     // Compute resolution scale factor
  319.     s = g_fScreenScaleFactor;
  320.  
  321.     // Create container with button interface
  322.     container = NewContainer(Gui_iBitmapButton);
  323.     SetScale(container,s);
  324.  
  325.     CatchEvent(container,e_GUI_Event_Mouse_Move);
  326.  
  327.     // Create a sprite with material and area index e_GUI_State_Enabled
  328.     sprite = NewSprite3D(_pMesh);
  329.  
  330.     // Get size of area of index e_GUI_State_Enabled
  331.     sx = GetMeshWidth(_pMesh) * s;
  332.     sy = GetMeshHeight(_pMesh) * s;
  333.  
  334.     // Strech container to area size
  335.     StretchTo(container,sx,sy);
  336.  
  337.     // Define default align left/top (quicker than zoom)
  338.     SetAlign(container,e_GUI_HAlign_Left,e_GUI_VAlign_Top);
  339.  
  340.     // Attach the sprite to this container
  341.     AttachSprite(container,sprite);
  342.  
  343.     return container;
  344. }
  345.  
  346. func Gui_Component NewCheckbox(Menu_Material _pMaterial)
  347. {
  348.     var Gui_dtCheckbox pdtCheckbox;
  349.     var Gui_Component container;
  350.  
  351.     // Create container with button interface
  352.     container = NewButton(_pMaterial);
  353.  
  354.     // Affect data pointer
  355.     pdtCheckbox = new Gui_dtCheckbox;
  356.     pdtCheckbox.bChecked = false;
  357.     SetData(container,pdtCheckbox);
  358.  
  359.     // Change interface to checkbox interface
  360.     SetInterface(container,Gui_iBitmapCheckbox);
  361.  
  362.     //mao debug for now
  363.     SetShadingMode(GetSprite(container),DLC_GouraudMode_ModulateDiffuse,DLC_GouraudMode_Decal);
  364.     SetColor(container,MakeARGB(255,255,255,255));
  365.  
  366.     return container;
  367. }
  368.  
  369. /*
  370.  *    Function        : Checkbox button initializer with text param
  371.  *    Parameters        : _pMaterial material pointer
  372.  *    Parameters        : _pFont material pointer
  373.  *    Parameters        : __sxTxt text
  374.  */
  375. func Gui_Component NewCheckbox_Text(Menu_Material _pMaterial,Menu_Material _pFont,szx _sxTxt)
  376. {
  377.     var Menu_Sprite sprite;
  378.     var Gui_Component caption,container,composite;
  379.     var i32x iArea;
  380.     var i32x wc,w,h;
  381.  
  382.     // Create an object that will contain Bitmap buton + caption
  383.     composite = NewObject(Gui_iCheckbox_Composite);
  384.     Transparent(composite);
  385.  
  386.     // Two component in composite button
  387.     SetComponentNumber(composite,2);
  388.  
  389.     // Create a caption that fit button
  390.     caption = NewCaption(_pFont,_sxTxt);
  391.     SetColor(caption,4278255360);
  392.     wc = SizeX(caption);
  393.     // Vertical Center text in caption
  394.     SetAlign(caption,e_GUI_HAlign_Left,e_GUI_VAlign_Center);
  395.  
  396.     // Disable caption
  397.     caption<<Disable();
  398.  
  399.     // Create A bitmap checkbox
  400.     container = NewCheckbox(_pMaterial);
  401.     // Get button size
  402.     w = SizeX(container);
  403.     h = SizeY(container);
  404.     // Stretch button to overwrite cation
  405.     Stretch(container,wc,0);
  406.  
  407.     // Move caption
  408.     Move(caption,w,0);
  409.     // Stretch caption to button height
  410.     StretchTo(caption,wc,h);
  411.  
  412.     // Mount containers into object
  413.     MountComponent(composite,caption);
  414.     MountComponent(composite,container);
  415.  
  416.     // Stretch composite to fit content
  417.     StretchTo(composite,w+wc,h);
  418.  
  419.     return composite;
  420. }
  421.  
  422. /*
  423.  *    Function        : RadioButton button initializer with text param
  424.  *    Parameters        : _pMaterial material pointer
  425.  *    Parameters        : _pFont material pointer
  426.  *    Parameters        : __sxTxt text
  427.  */
  428. func Gui_Component NewRadioButton_Text(Menu_Material _pMaterial,Menu_Material _pFont,szx _sxTxt,i32x _iValue)
  429. {
  430.     var Menu_Sprite sprite;
  431.     var Gui_Component caption,container,composite;
  432.     var Gui_dtRadioButtonComposite pdtData;
  433.     var i32x iArea;
  434.     var i32x wc,w,h;
  435.  
  436.     // Create an object that will contain Bitmap buton + caption
  437.     composite = NewObject(Gui_iRadioButton_Composite);
  438.     Transparent(composite);
  439.  
  440.     pdtData = new Gui_dtRadioButtonComposite;
  441.  
  442.     // Affect data to composite
  443.     SetData(composite,pdtData);
  444.  
  445.     // Two component in composite button
  446.     SetComponentNumber(composite,2);
  447.  
  448.     // Create a caption that fit button
  449.     caption = NewCaption(_pFont,_sxTxt);
  450.     Clip(caption);
  451.     wc = SizeX(caption);
  452.     // Vertical Center text in caption
  453.     SetAlign(caption,e_GUI_HAlign_Left,e_GUI_VAlign_Center);
  454.  
  455.     // Disable caption
  456.     caption<<Disable();
  457.  
  458.     // Create A bitmap checkbox
  459.     container = NewRadioButton(_pMaterial,_iValue);
  460.     // Get button size
  461.     w = SizeX(container);
  462.     h = SizeY(container);
  463.     // Stretch button to overwrite cation
  464.     Stretch(container,wc,0);
  465.  
  466.     // Move caption
  467.     Move(caption,w,0);
  468.     // Stretch caption to button height
  469.     StretchTo(caption,wc,h);
  470.  
  471.     // Mount containers into object
  472.     MountComponent(composite,caption);
  473.     MountComponent(composite,container);
  474.     pdtData.gcCaption = caption;
  475.     pdtData.gcRadioButton = container;
  476.  
  477.     // Stretch composite to fit content
  478.     StretchTo(composite,w+wc,h);
  479.  
  480.     return composite;
  481. }
  482.  
  483.  
  484.  
  485. /*
  486.  *    Function        : RadioButton button initializer with text param
  487.  *    Parameters        : _pMaterial material pointer
  488.  *    Parameters        : _pFont material pointer
  489.  *    Parameters        : __sxTxt text
  490.  */
  491. func Gui_Component NewRadioButton_CenterTextExt(Menu_Material _pMaterial,Menu_Material _pFont,szx _sxTxt,i32x _iValue,i32x _iWidth,i32x _iHeight)
  492. {
  493.     var Menu_Sprite sprite;
  494.     var Gui_Component caption,container,composite;
  495.     var Gui_dtRadioButtonComposite pdtData;
  496.     var i32x iArea;
  497.     var i32x w,h;
  498.  
  499.     // Create an object that will contain Bitmap buton + caption over the 
  500.     composite = NewObject(Gui_iRadioButton_Composite);
  501.     Transparent(composite);
  502.  
  503.     pdtData = new Gui_dtRadioButtonComposite;
  504.  
  505.     // Affect data to composite
  506.     SetData(composite,pdtData);
  507.  
  508.     // Two component in composite button
  509.     SetComponentNumber(composite,2);
  510.  
  511.     // Create a caption that fit button
  512.     caption = NewCaption(_pFont,_sxTxt);
  513.     if(_iWidth==0)
  514.         w = SizeX(caption);
  515.     else 
  516.         w = _iWidth;
  517.  
  518.     if(_iHeight==0)
  519.         h = SizeY(caption);
  520.     else 
  521.         h = _iHeight;
  522.  
  523.     // Vertical Center text in caption
  524.     SetAlign(caption,e_GUI_HAlign_Center,e_GUI_VAlign_Center);
  525.  
  526.     // Disable caption
  527.     caption<<Disable();
  528.  
  529.     // Create A bitmap checkbox
  530.     container = NewRadioButton(_pMaterial,_iValue);
  531.     SetAlign(container,e_GUI_HAlign_Zoom,e_GUI_VAlign_Zoom);
  532.     StretchTo(container,w,h);
  533.  
  534.     // Mount containers into object
  535.     MountComponent(composite,container);
  536.     MountComponent(composite,caption);
  537.     
  538.     pdtData.gcCaption = caption;
  539.     pdtData.gcRadioButton = container;
  540.  
  541.     // Stretch composite to fit content
  542.     StretchTo(composite,w,h);
  543.  
  544.     return composite;
  545. }
  546.  
  547.  
  548. func Gui_Component NewRadioButton_CenterText(Menu_Material _pMaterial,Menu_Material _pFont,szx _sxTxt,i32x _iValue)
  549. {
  550.     return NewRadioButton_CenterTextExt(_pMaterial,_pFont,_sxTxt,_iValue,0,0);
  551. }
  552.  
  553.  
  554. func Gui_Component NewRadioButton(Menu_Material _pMaterial,i32x _iValue)
  555. {
  556.     var Gui_dtRadioButton pdtRadio;
  557.     var Gui_Component container;
  558.  
  559.     // Create container with button interface
  560.     container = NewCheckbox(_pMaterial);
  561.  
  562.     // Affect data pointer
  563.     pdtRadio = new Gui_dtRadioButton;
  564.     pdtRadio.bChecked = false;
  565.     pdtRadio.iValue = _iValue;
  566.  
  567.  
  568.     // Change interface to checkbox interface
  569.     AddInterface(container,Gui_iBitmapRadioButton,pdtRadio);
  570.  
  571.     return container;
  572. }
  573.  
  574. /*
  575.  *    Function        : Button_Init button initializer 
  576.  *    Parameters        : _pMaterial material pointer
  577.  */
  578. func Gui_Component NewButton_Text(Menu_Material _pFont,szx _sxTxt,f32x _sx,f32x _sy)
  579. {
  580.     var Menu_Sprite sprite;
  581.     var Gui_Component container;
  582.     var f32x sx,sy;
  583.     var i32x iArea;
  584.  
  585.     // Create container with button interface
  586.     container = NewContainer(Gui_iBitmapButton);
  587.     CatchEvent(container,e_GUI_Event_Mouse_Move);
  588.  
  589.     // Create a sprite with material and area index e_GUI_State_Enabled
  590.     sprite = NewSprite2D(_pFont);
  591.     SetText(sprite,_sxTxt);
  592.  
  593.     // Strech container to area size
  594.     StretchTo(container,_sx,_sy);
  595.  
  596.     // Define default align left/top (quicker than zoom)
  597.     SetAlign(container,e_GUI_HAlign_Center,e_GUI_VAlign_Center);
  598.  
  599.     // Attach the sprite to this container
  600.     AttachSprite(container,sprite);
  601.  
  602.     // Tell Gui to clip this sprite to container size
  603.     Clip(container);
  604.  
  605.     return container;
  606. }
  607.  
  608. /*
  609.  *    Function        : Button_Init button initializer with size param
  610.  *    Parameters        : _pMaterial material pointer
  611.  *    Parameters        : _sx,_sy wanted container size in pixel
  612.  *    Remarks            : sprite will be zoomed to fit container don't need to clip
  613.  */
  614. func Gui_Component NewButton_Size(Menu_Material _pMaterial,f32x _sx, f32x _sy)
  615. {
  616.     var Menu_Sprite sprite;
  617.     var Gui_Component component;
  618.     var i32x iArea;
  619.  
  620.     // Create container with button interface
  621.     component = NewContainer(Gui_iBitmapButton);
  622.  
  623.     // Create a sprite with material and area index e_GUI_State_Enabled
  624.     sprite = NewSprite2D(_pMaterial);
  625.     iArea = e_GUI_State_Enabled;
  626.     SetArea(sprite,iArea);
  627.  
  628.     // Strech container to wanted size
  629.     StretchTo(component,_sx,_sy);
  630.  
  631.     // Zoom sprite to fit container
  632.     SetAlign(component,e_GUI_HAlign_Zoom,e_GUI_VAlign_Zoom);
  633.  
  634.     // Attach the sprite to this container
  635.     AttachSprite(component,sprite);
  636.  
  637.     return component;
  638. }
  639.  
  640. /*
  641.  *    Function        : Button_Init button initializer with size param
  642.  *    Parameters        : _pMaterial material pointer
  643.  *    Parameters        : _pFont material pointer
  644.  *    Parameters        : __sxTxt text
  645.  */
  646. func Gui_Component NewButton_CenterText(Menu_Material _pMaterial,Menu_Material _pFont,szx _sxTxt)
  647. {
  648.     var Menu_Sprite sprite;
  649.     var Gui_Component caption,container,composite;
  650.     var i32x iArea;
  651.     var i32x w,h;
  652.  
  653.     // Create an object that will contain Bitmap buton + caption
  654.     composite = NewObject(Gui_iButtonComposite);
  655.  
  656.     // Two component in composite button
  657.     SetComponentNumber(composite,2);
  658.  
  659.     // Create A bitmap Button
  660.     container = NewButton(_pMaterial);
  661.     // Get button size
  662.     w = SizeX(container);
  663.     h = SizeY(container);
  664.  
  665.     // Create a caption that fit button
  666.     caption = NewCaption(_pFont,_sxTxt);
  667.     StretchTo(caption,w,h);
  668.     // Center text in caption
  669.     SetAlign(caption,e_GUI_HAlign_Center,e_GUI_VAlign_Center);
  670.  
  671.     // Disable caption
  672.     caption<<Disable();
  673.  
  674.     // Mount containers into object
  675.     MountComponent(composite,container);
  676.     MountComponent(composite,caption);
  677.  
  678.     // Stretch composite to fit button
  679.     StretchTo(composite,w,h);
  680.  
  681.     return composite;
  682. }
  683.  
  684. /*
  685.  *    Function        : Button_Init button initializer with size param
  686.  *    Parameters        : _pMaterial material pointer
  687.  *    Parameters        : _pFont material pointer
  688.  *    Parameters        : __sxTxt text
  689.  */
  690. func Gui_Component NewButton_FrameText(Menu_Material _pMaterialRight, Menu_Material _pMaterialCenter, Menu_Material _pMaterialLeft, Menu_Material _pFont,szx _sxTxt)
  691. {
  692.     var Menu_Sprite sprite;
  693.     var Gui_Component gcText, gcRightButton, gcCenterButton, gcLeftButton, gcActifButton, composite;
  694.     var Gui_dtFrameTextButton    pdtData;
  695.     var i32x iArea;
  696.     var i32x w_button,h_button,w_text, w;
  697.  
  698.     // Create an object that will contain Bitmap buton + gcText
  699.     composite = NewObject(Gui_iButtonComposite);
  700.  
  701.     // Two component in composite button
  702.     SetComponentNumber(composite,3);
  703.  
  704.     // Create a gcText that fit button
  705.     gcText = NewCaption(_pFont,_sxTxt);
  706.     w_text = PrecalcTextWidth(GetSprite(gcText),_sxTxt);
  707.     // Center text in gcText
  708.     SetAlign(gcText,e_GUI_HAlign_Center,e_GUI_VAlign_Center);
  709.  
  710.     // Disable text
  711.     gcText<<Disable();
  712.  
  713.     // Create A bitmap Button (right button)
  714.     gcRightButton = NewButton(_pMaterialRight);
  715.     // Get button size
  716.     w_button = SizeX(gcRightButton);
  717.     h_button = SizeY(gcRightButton);
  718.     // align button
  719.     SetAlign(gcRightButton,e_GUI_HAlign_Right,e_GUI_VAlign_Center);
  720.  
  721.     // create a bitmap button (center button)
  722.     gcCenterButton = NewButton(_pMaterialCenter);
  723.     SetAlign(gcCenterButton, e_GUI_HAlign_Zoom, e_GUI_VAlign_Center);
  724.  
  725.     // Create A bitmap Button (left button)
  726.     gcLeftButton = NewButton(_pMaterialLeft);
  727.     // align button
  728.     SetAlign(gcLeftButton,e_GUI_HAlign_Left,e_GUI_VAlign_Center);
  729.  
  730.     // Stretch button and text
  731.     w = w_text+w_button*2;
  732.     StretchTo(gcText,w,h_button);
  733.     StretchTo(gcRightButton,w,h_button);
  734.     StretchTo(gcCenterButton, w-2*w_button, h_button);
  735.     StretchTo(gcLeftButton, w, h_button);
  736.     MoveTo(gcCenterButton, w_button, 0);
  737.  
  738.     // Set Data
  739.     pdtData = new Gui_dtFrameTextButton;
  740.     SetData(composite,pdtData);
  741.     pdtData.gcRightButton = gcRightButton;
  742.     pdtData.gcCenterButton = gcCenterButton;
  743.     pdtData.gcLeftButton = gcLeftButton;
  744.     pdtData.gcText = gcText;
  745.  
  746.     // Mount containers into object
  747.     MountComponent(composite,gcRightButton);
  748.     MountComponent(composite,gcCenterButton);
  749.     MountComponent(composite,gcLeftButton);
  750.     MountComponent(composite,gcText);
  751.  
  752.  
  753.     // Stretch composite to fit button
  754.     StretchTo(composite,w,h_button);
  755.  
  756.     return composite;
  757. }
  758.  
  759.  
  760. /*
  761.  *    Function : init a standard button according to CM2 graphic chart
  762.  *    Parameters : _sxTxt -> button caption
  763.  */
  764. func Gui_Component NewCM2Button(szx _sxTxt)
  765. {
  766.     return NewButton_FrameText(smBtnBlueRight, smBtnBlueCenter, smBtnBlueLeft, smBauer, _sxTxt);
  767. }
  768.  
  769. func Gui_Component NewCM2InRaceButton2(szx _sxTxt)
  770. {
  771.     return NewButton_FrameText(smBtnIGGrey2Right, smBtnIGGrey2Center, smBtnIGGrey2Left, smTrebuchet, _sxTxt);
  772. }
  773.  
  774. /*
  775.  *    Function        : NewCM2InRaceButton button initializer
  776.  *    Parameters        : _sxTxt -> button caption; _sxTxt2 -> the other button caption to be compare with
  777.  *                        _sxContextualHelp -> contextual caption
  778.  */
  779. func Gui_Component NewCM2InRaceButton(szx _sxTxt, szx _sxTxt2, szx _szContextualCaption)
  780. {
  781.     var Menu_Sprite sprite;
  782.     var Gui_Component gcText, gcRightButton, gcCenterButton, gcLeftButton, gcActifButton, composite;
  783.     var Gui_dtCM2InRaceButton    pdtData;
  784.     var i32x iArea;
  785.     var i32x w_button,h_button,w_text,w_text2, w;
  786.  
  787.     // Create an object that will contain Bitmap buton + gcText
  788.     composite = NewObject(Gui_iCM2InRaceButton);
  789.  
  790.     // Two component in composite button
  791.     SetComponentNumber(composite,3);
  792.  
  793.     // Create a gcText that fit button
  794.     gcText = NewCaption(smTrebuchet,_sxTxt);
  795.     w_text = PrecalcTextWidth(GetSprite(gcText),_sxTxt);
  796.     w_text2 = PrecalcTextWidth(GetSprite(gcText),_sxTxt2);
  797.     if(w_text2>w_text)
  798.         w_text=w_text2;
  799.  
  800.     // Center text in gcText
  801.     SetAlign(gcText,e_GUI_HAlign_Center,e_GUI_VAlign_Center);
  802.     
  803.     // Disable text
  804.     gcText<<Disable();
  805.  
  806.     // Create A bitmap Button (right button)
  807.     gcRightButton = NewButton(smBtnIGGrey2Right);
  808.     // Get button size
  809.     w_button = SizeX(gcRightButton);
  810.     h_button = SizeY(gcRightButton);
  811.     // align button
  812.     SetAlign(gcRightButton,e_GUI_HAlign_Right,e_GUI_VAlign_Center);
  813.  
  814.     // create a bitmap button (center button)
  815.     gcCenterButton = NewButton(smBtnIGGrey2Center);
  816.     SetAlign(gcCenterButton, e_GUI_HAlign_Zoom, e_GUI_VAlign_Center);
  817.  
  818.     // Create A bitmap Button (left button)
  819.     gcLeftButton = NewButton(smBtnIGGrey2Left);
  820.     // align button
  821.     SetAlign(gcLeftButton,e_GUI_HAlign_Left,e_GUI_VAlign_Center);
  822.  
  823.     // Stretch button and text
  824.     w = w_text+w_button*2;
  825.     StretchTo(gcText,w,h_button);
  826.     StretchTo(gcRightButton,w,h_button);
  827.     StretchTo(gcCenterButton, w-2*w_button, h_button);
  828.     StretchTo(gcLeftButton, w, h_button);
  829.     MoveTo(gcCenterButton, w_button, 0);
  830.  
  831.     // Set Data
  832.     pdtData = new Gui_dtCM2InRaceButton;
  833.     SetData(composite,pdtData);
  834.     pdtData.gcRightButton = gcRightButton;
  835.     pdtData.gcCenterButton = gcCenterButton;
  836.     pdtData.gcLeftButton = gcLeftButton;
  837.     pdtData.gcText = gcText;
  838.     pdtData.bChecked = 0;
  839.     pdtData.szContextualCaption = _szContextualCaption;
  840.  
  841.     // Mount containers into object
  842.     MountComponent(composite,gcRightButton);
  843.     MountComponent(composite,gcCenterButton);
  844.     MountComponent(composite,gcLeftButton);
  845.     MountComponent(composite,gcText);
  846.  
  847.  
  848.     // Stretch composite to fit button
  849.     StretchTo(composite,w,h_button);
  850.  
  851.     return composite;
  852. }
  853.  
  854.  
  855.  
  856. /*
  857.  *    Function        : Composite Button click callback
  858.  *    Remarks            : Simply transfer message to parent
  859.  *    Message            : "Click"
  860.  */
  861. func void HelpButtonComposite_OnClick(Gui_Component _pClicked)
  862. {
  863.     var Gui_Component parent,pthis; 
  864.     var Gui_dtFrameTextButton pdtData;
  865.  
  866.     pthis = GetThis();
  867.     pdtData = GetData(pthis);
  868.     parent = GetParent(pthis);
  869.  
  870.     /*
  871.     // change button style
  872.     SetArea(GetSprite(pdtData.gcRightButton),1);
  873.     SetArea(GetSprite(pdtData.gcCenterButton),1);
  874.     SetArea(GetSprite(pdtData.gcLeftButton),1);
  875.     SetColor(pdtData.gcText, MakeARGB(255, 255, 67, 0));
  876.     
  877.     // send mesg to parent
  878.     */
  879.     parent<<Click(pthis);
  880. }
  881.  
  882. /*
  883.  *    Function        : Composite Button on mouse down callback
  884.  */
  885. func i32x HelpButtonComposite_OnMouseDown(i32x _iX,i32x _iY,i32x _iButton)
  886. {
  887.     var Gui_Component pthis; 
  888.     var Gui_dtFrameTextButton pdtData;
  889.  
  890.     pthis = GetThis();
  891.     pdtData = GetData(pthis);
  892.  
  893.     // change button style
  894.     SetArea(GetSprite(pdtData.gcRightButton),2);
  895.     SetArea(GetSprite(pdtData.gcCenterButton),2);
  896.     SetArea(GetSprite(pdtData.gcLeftButton),2);
  897.     SetColor(pdtData.gcText, MakeARGB(255, 255, 67, 0));
  898. }
  899.  
  900. func i32x HelpButtonComposite_OnMouseUp(i32x _iX,i32x _iY,i32x _iButton)
  901. {
  902.     var Gui_Component pthis; 
  903.     var Gui_dtFrameTextButton pdtData;
  904.  
  905. //    println("HelpButtonComposite_OnMouseUp");
  906.  
  907.     pthis = GetThis();
  908.     pdtData = GetData(pthis);
  909.  
  910.     // change button style
  911.     SetArea(GetSprite(pdtData.gcRightButton),0);
  912.     SetArea(GetSprite(pdtData.gcCenterButton),0);
  913.     SetArea(GetSprite(pdtData.gcLeftButton),0);
  914.     SetColor(pdtData.gcText, MakeARGB(255, 255, 255, 255));
  915. }
  916.  
  917.  
  918.  
  919. /*
  920.  *    Function        : Button_Init button initializer with size param
  921.  *    Parameters        : _pMaterial material pointer
  922.  *    Parameters        : _pFont material pointer
  923.  *    Parameters        : __sxTxt text
  924.     * Works with help hint !!!
  925.  */
  926. func Gui_Component NewButton_FrameTextWithHelp(Menu_Material _pMaterialRight, Menu_Material _pMaterialCenter, Menu_Material _pMaterialLeft, Menu_Material _pFont,szx _sxTxt)
  927. {
  928.     var Menu_Sprite sprite;
  929.     var Gui_Component gcText, gcRightButton, gcCenterButton, gcLeftButton, gcActifButton, composite;
  930.     var Gui_dtFrameTextButton    pdtData;
  931.     var i32x iArea;
  932.     var i32x w_button,h_button,w_text, w;
  933.  
  934.     // Create an object that will contain Bitmap buton + gcText
  935.     composite = NewObject(Gui_iHelpButtonComposite);
  936.  
  937.     // Two component in composite button
  938.     SetComponentNumber(composite,3);
  939.  
  940.     // Create a gcText that fit button
  941.     gcText = NewCaption(_pFont,_sxTxt);
  942.     w_text = PrecalcTextWidth(GetSprite(gcText),_sxTxt);
  943.     // Center text in gcText
  944.     SetAlign(gcText,e_GUI_HAlign_Center,e_GUI_VAlign_Center);
  945.  
  946.     // Disable text
  947.     gcText<<Disable();
  948.  
  949.     // Create A bitmap Button (right button)
  950.     gcRightButton = NewButton(_pMaterialRight);
  951.     // Get button size
  952.     w_button = SizeX(gcRightButton);
  953.     h_button = SizeY(gcRightButton);
  954.     // align button
  955.     SetAlign(gcRightButton,e_GUI_HAlign_Right,e_GUI_VAlign_Center);
  956.  
  957.     // create a bitmap button (center button)
  958.     gcCenterButton = NewButton(_pMaterialCenter);
  959.     SetAlign(gcCenterButton, e_GUI_HAlign_Zoom, e_GUI_VAlign_Center);
  960.  
  961.     // Create A bitmap Button (left button)
  962.     gcLeftButton = NewButton(_pMaterialLeft);
  963.     // align button
  964.     SetAlign(gcLeftButton,e_GUI_HAlign_Left,e_GUI_VAlign_Center);
  965.  
  966.     // Stretch button and text
  967.     w = w_text+w_button*2;
  968.     StretchTo(gcText,w,h_button);
  969.     StretchTo(gcRightButton,w,h_button);
  970.     StretchTo(gcCenterButton, w-2*w_button, h_button);
  971.     StretchTo(gcLeftButton, w, h_button);
  972.     MoveTo(gcCenterButton, w_button, 0);
  973.  
  974.     // Set Data
  975.     pdtData = new Gui_dtFrameTextButton;
  976.     SetData(composite,pdtData);
  977.     pdtData.gcRightButton = gcRightButton;
  978.     pdtData.gcCenterButton = gcCenterButton;
  979.     pdtData.gcLeftButton = gcLeftButton;
  980.     pdtData.gcText = gcText;
  981.  
  982.     // Mount containers into object
  983.     MountComponent(composite,gcRightButton);
  984.     MountComponent(composite,gcCenterButton);
  985.     MountComponent(composite,gcLeftButton);
  986.     MountComponent(composite,gcText);
  987.  
  988.  
  989.     // Stretch composite to fit button
  990.     StretchTo(composite,w,h_button);
  991.  
  992.     return composite;
  993. }
  994.  
  995.  
  996. func Gui_Component NewCM2InRaceButton1(szx _sxTxt)
  997. {
  998.     return NewButton_FrameTextWithHelp(smBtnIGGrey1Right, smBtnIGGrey1Center, smBtnIGGrey1Left, smTrebuchet, _sxTxt);
  999. }
  1000.  
  1001.  
  1002.  
  1003. /*
  1004.  *    Function        : NewCM2BmpButton button initializer (bitmap button which handle the mouse message)
  1005.  *    Parameters        : _pMaterial material pointer; _iIndex sprite index; _iOffset number of different bitmaps (usually just one)
  1006.  */
  1007. func Gui_Component NewCM2BmpButton(Menu_Material _pMaterial, i32x _iIndex, i32x _iOffset, szx _szContextualCaption)
  1008. {
  1009.     var Menu_Sprite sprite;
  1010.     var Gui_Component container;
  1011.     var Gui_dtCM2BmpButton pdtCM2BmpButton;
  1012.     var f32x sx,sy;
  1013.     var i32x iArea;
  1014.  
  1015.     // Create container with button interface
  1016.     container = NewContainer(Gui_iCM2BmpButton);
  1017.     CatchEvent(container,e_GUI_Event_Mouse_Move);
  1018.  
  1019.     // Affect data pointer
  1020.     pdtCM2BmpButton = new Gui_dtCM2BmpButton;
  1021.     pdtCM2BmpButton.bChecked = false;
  1022.     pdtCM2BmpButton.iIndex = _iIndex;
  1023.     pdtCM2BmpButton.iOffset = _iOffset;
  1024.     pdtCM2BmpButton.szContextualCaption = _szContextualCaption;
  1025.     SetData(container,pdtCM2BmpButton);
  1026.  
  1027.     // Create a sprite with material and area index e_GUI_State_Enabled
  1028.     sprite = NewSprite2D(_pMaterial);
  1029.     iArea = e_GUI_State_Enabled;
  1030.     SetArea(sprite,iArea);
  1031.  
  1032.     // Get size of area of index e_GUI_State_Enabled
  1033.     sx = GetAreaWidth(_pMaterial,iArea);
  1034.     sy = GetAreaHeight(_pMaterial,iArea);
  1035.  
  1036.     // Strech container to area size
  1037.     StretchTo(container,sx,sy);
  1038.  
  1039.     // Define default align left/top (quicker than zoom)
  1040.     SetAlign(container,e_GUI_HAlign_Left,e_GUI_VAlign_Top);
  1041.  
  1042.     // Attach the sprite to this container
  1043.     AttachSprite(container,sprite);
  1044.  
  1045.     // Tell Gui to clip this sprite to container size
  1046.     Clip(container);
  1047.  
  1048.     return container;
  1049. }
  1050.  
  1051.  
  1052.  
  1053. /*
  1054.  *    Function        : Button Mouse click callback
  1055.  *    Remarks            : Test left click
  1056.  *    Remarks            : Push click message to parent
  1057.  *    Message            : "MouseClick"
  1058.  */
  1059. func i32x Button_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton)
  1060. {
  1061.     var Gui_Component pthis; 
  1062.     var Gui_Component parent;
  1063.  
  1064.     if(_iButton == e_Gui_Mouse_Left_Button)
  1065.     {
  1066.         pthis = GetThis();
  1067.         parent = GetParent(pthis);
  1068.         parent<<Click(pthis);
  1069.     }
  1070.     else if(_iButton == e_Gui_Mouse_Right_Button)
  1071.     {
  1072.         pthis = GetThis();
  1073.         parent = GetParent(pthis);
  1074.         parent<<RightClick(pthis);
  1075.     }
  1076.     else if(_iButton == e_Gui_Mouse_Middle_Button)
  1077.     {
  1078.         pthis = GetThis();
  1079.         parent = GetParent(pthis);
  1080.         parent<<MiddleClick(pthis);
  1081.     }
  1082.     return 0;
  1083. }
  1084.  
  1085. func i32x Checkbox_bIsChecked(Gui_Component _pCheckbox)
  1086. {
  1087.     var Gui_dtCheckbox pdtCheckbox;
  1088.     pdtCheckbox = GetData(_pCheckbox);
  1089.     return (pdtCheckbox.bChecked==true);
  1090. }
  1091.  
  1092. func i32x Checkbox_OnQuietCheck()
  1093. {
  1094.     var Gui_dtCheckbox pdtCheckbox;
  1095.     var Gui_Component pthis; 
  1096.     
  1097.     pthis = GetThis();
  1098.     pdtCheckbox = GetData(pthis);
  1099.  
  1100.     if(pdtCheckbox.bChecked==false)
  1101.     {
  1102.         pdtCheckbox.bChecked = true;
  1103.         
  1104.         SetArea(GetSprite(pthis),1);
  1105.         SetArea(GetSprite(pthis),1);
  1106.     }
  1107.     return 1;
  1108. }
  1109.  
  1110. func i32x Checkbox_OnQuietUncheck()
  1111. {
  1112.     var Gui_dtCheckbox pdtCheckbox;
  1113.     var Gui_Component pthis; 
  1114.     
  1115.     pthis = GetThis();
  1116.     pdtCheckbox = GetData(pthis);
  1117.  
  1118.     if(pdtCheckbox.bChecked==true)
  1119.     {
  1120.         pdtCheckbox.bChecked = false;
  1121.         
  1122.         SetArea(GetSprite(pthis),0);
  1123.         SetArea(GetSprite(pthis),0);
  1124.     }
  1125.     return 1;
  1126. }
  1127.  
  1128. func i32x Checkbox_OnEnable()
  1129. {
  1130.     var Gui_dtCheckbox pdtCheckbox;
  1131.     var Gui_Component pthis; 
  1132.     
  1133.     pthis = GetThis();
  1134.     pdtCheckbox = GetData(pthis);
  1135.     if(pdtCheckbox.bChecked==false)
  1136.     {
  1137.         SetArea(GetSprite(pthis),0);
  1138.         SetArea(GetSprite(pthis),0);
  1139.     }
  1140.     else
  1141.     {
  1142.         SetArea(GetSprite(pthis),1);
  1143.         SetArea(GetSprite(pthis),1);
  1144.     }
  1145. }
  1146. func i32x Checkbox_OnDisable()
  1147. {
  1148.     var Gui_dtCheckbox pdtCheckbox;
  1149.     var Gui_Component pthis; 
  1150.     
  1151.     pthis = GetThis();
  1152.     pdtCheckbox = GetData(pthis);
  1153.     //SetArea(GetSprite(pthis),3);
  1154.     //SetArea(GetSprite(pthis),3);
  1155. }
  1156.  
  1157. func void RadioButton_OnQuietCheck(i32x _iValue)
  1158. {
  1159.     var Gui_dtRadioButton pdtRadio;
  1160.     var Gui_Component pthis; 
  1161.     
  1162.     pthis = GetThis();
  1163.     pdtRadio = GetData(pthis);
  1164.  
  1165.     if(pdtRadio.iValue == _iValue)
  1166.     {
  1167.         pdtRadio.bChecked = true;
  1168.         SetArea(GetSprite(pthis),1);
  1169.         SetArea(GetSprite(pthis),1);
  1170.     }
  1171.     else
  1172.     {
  1173.         pdtRadio.bChecked = false;
  1174.         SetArea(GetSprite(pthis),0);
  1175.         SetArea(GetSprite(pthis),0);
  1176.     }
  1177. }
  1178.  
  1179. func void RadioButtonComposite_OnQuietCheck(i32x _iValue)
  1180. {
  1181.     var Gui_dtRadioButtonComposite pdtData;
  1182.     var Gui_Component pthis; 
  1183.     
  1184.     pthis = GetThis();
  1185.     pdtData = GetData(pthis);
  1186.  
  1187.     pdtData.gcRadioButton<<QuietRadioCheck(_iValue);
  1188. }
  1189.  
  1190. /*
  1191.  *    Function        : Checkbox Mouse click callback
  1192.  *    Remarks            : Test left click
  1193.  *    Remarks            : Check or uncheck checkbox
  1194.  *    Message            : "MouseClick"
  1195.  */
  1196. func i32x Checkbox_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton)
  1197. {
  1198.     var Gui_dtCheckbox pdtCheckbox;
  1199.     var Gui_Component pthis; 
  1200.     var Gui_Component parent;
  1201.     if(_iButton == e_Gui_Mouse_Left_Button)
  1202.     {
  1203.         pthis = GetThis();
  1204.         parent = GetParent(pthis);
  1205.         
  1206.         pdtCheckbox = GetData(pthis);
  1207.         if(pdtCheckbox.bChecked==false)
  1208.         {
  1209.             Checkbox_OnQuietCheck();
  1210.             parent<<Click(pthis);
  1211.             parent<<Check(pthis);
  1212.         }
  1213.         else
  1214.         {
  1215.             Checkbox_OnQuietUncheck();
  1216.             parent<<Click(pthis);
  1217.             parent<<Uncheck(pthis);
  1218.         }
  1219.         return 1;
  1220.     }
  1221.     else if(_iButton == e_Gui_Mouse_Right_Button)
  1222.     {
  1223.         pthis = GetThis();
  1224.         parent = GetParent(pthis);
  1225.         parent<<RightClick(pthis);
  1226.         return 1;
  1227.     }
  1228.     else if(_iButton == e_Gui_Mouse_Middle_Button)
  1229.     {
  1230.         pthis = GetThis();
  1231.         parent = GetParent(pthis);
  1232.         parent<<MiddleClick(pthis);
  1233.         return 1;
  1234.     }
  1235.     return 0;
  1236. }
  1237.  
  1238. /*
  1239.  *    Function        : Radio button Mouse click callback
  1240.  *    Remarks            : Test left click
  1241.  *    Remarks            : Check or uncheck checkbox
  1242.  *    Message            : "MouseClick"
  1243.  */
  1244. func i32x RadioButton_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton)
  1245. {
  1246.     var Gui_dtRadioButton pdtRadio;
  1247.     var Gui_Component pthis; 
  1248.     var Gui_Component parent;
  1249.     if(_iButton == e_Gui_Mouse_Left_Button)
  1250.     {
  1251.         pthis = GetThis();
  1252.         parent = GetParent(pthis);
  1253.         
  1254.         pdtRadio = GetData(pthis);
  1255.         if(pdtRadio.bChecked==false)
  1256.         {
  1257.             RadioButton_OnQuietCheck(pdtRadio.iValue);
  1258.             parent<<RadioCheck(pthis,pdtRadio.iValue);
  1259.         }
  1260.         parent<<Click(pthis);
  1261.         return 1;
  1262.     }
  1263.     else if(_iButton == e_Gui_Mouse_Right_Button)
  1264.     {
  1265.         pthis = GetThis();
  1266.         parent = GetParent(pthis);
  1267.         parent<<RightClick(pthis);
  1268.         return 1;
  1269.     }
  1270.     else if(_iButton == e_Gui_Mouse_Middle_Button)
  1271.     {
  1272.         pthis = GetThis();
  1273.         parent = GetParent(pthis);
  1274.         parent<<MiddleClick(pthis);
  1275.         return 1;
  1276.     }
  1277.     return 0;
  1278. }
  1279.  
  1280. /*
  1281.  *    Function        : Composite Button click callback
  1282.  *    Remarks            : Simply transfer message to parent
  1283.  *    Message            : "Click"
  1284.  */
  1285. func void ButtonComposite_OnClick(Gui_Component _pClicked)
  1286. {
  1287.     var Gui_Component parent,pthis; 
  1288.     var Gui_dtFrameTextButton pdtData;
  1289.  
  1290.     pthis = GetThis();
  1291.     pdtData = GetData(pthis);
  1292.     parent = GetParent(pthis);
  1293.  
  1294.     // change button style
  1295.     SetArea(GetSprite(pdtData.gcRightButton),1);
  1296.     SetArea(GetSprite(pdtData.gcCenterButton),1);
  1297.     SetArea(GetSprite(pdtData.gcLeftButton),1);
  1298.     SetColor(pdtData.gcText, MakeARGB(255, 255, 67, 0));
  1299.     
  1300.     // send mesg to parent
  1301.     parent<<Click(pthis);
  1302. }
  1303.  
  1304. /*
  1305.  *    Function        : Composite Button enter callback
  1306.  */
  1307. func i32x ButtonComposite_OnMouseEnter(i32x _iX,i32x _iY)
  1308. {
  1309.     var Gui_Component pthis; 
  1310.     var Gui_dtFrameTextButton pdtData;
  1311.  
  1312.     pthis = GetThis();
  1313.     pdtData = GetData(pthis);
  1314.  
  1315.     // change button style
  1316.     SetArea(GetSprite(pdtData.gcRightButton),0);
  1317.     SetArea(GetSprite(pdtData.gcCenterButton),0);
  1318.     SetArea(GetSprite(pdtData.gcLeftButton),0);
  1319.     SetColor(pdtData.gcText, MakeARGB(255, 255, 67, 0));
  1320. }
  1321.  
  1322. /*
  1323.  *    Function        : Composite Button leave callback
  1324.  */
  1325. func i32x ButtonComposite_OnMouseLeave(i32x _iX,i32x _iY)
  1326. {
  1327.     var Gui_Component pthis; 
  1328.     var Gui_dtFrameTextButton pdtData;
  1329.  
  1330.     pthis = GetThis();
  1331.     pdtData = GetData(pthis);
  1332.  
  1333.     // change button style
  1334.     SetArea(GetSprite(pdtData.gcRightButton),0);
  1335.     SetArea(GetSprite(pdtData.gcCenterButton),0);
  1336.     SetArea(GetSprite(pdtData.gcLeftButton),0);
  1337.     SetColor(pdtData.gcText, MakeARGB(255, 255, 255, 255));
  1338. }
  1339.  
  1340. /*
  1341.  *    Function        : Composite Button on mouse down callback
  1342.  */
  1343. func i32x ButtonComposite_OnMouseDown(i32x _iX,i32x _iY,i32x _iButton)
  1344. {
  1345.     var Gui_Component pthis; 
  1346.     var Gui_dtFrameTextButton pdtData;
  1347.  
  1348.     pthis = GetThis();
  1349.     pdtData = GetData(pthis);
  1350.  
  1351.     // change button style
  1352.     SetArea(GetSprite(pdtData.gcRightButton),2);
  1353.     SetArea(GetSprite(pdtData.gcCenterButton),2);
  1354.     SetArea(GetSprite(pdtData.gcLeftButton),2);
  1355.     SetColor(pdtData.gcText, MakeARGB(255, 255, 67, 0));
  1356. }
  1357.  
  1358. /*
  1359.  *    Function        : Button enter callback
  1360.  */
  1361. func i32x ButtonDyn_OnMouseEnter(i32x _iX,i32x _iY)
  1362. {
  1363.     var Gui_Component pthis; 
  1364.  
  1365.     pthis = GetThis();
  1366.  
  1367.     // change button style
  1368.     SetArea(GetSprite(pthis),1);
  1369. }
  1370.  
  1371. /*
  1372.  *    Function        :  Button leave callback
  1373.  */
  1374. func i32x ButtonDyn_OnMouseLeave(i32x _iX,i32x _iY)
  1375. {
  1376.     var Gui_Component pthis; 
  1377.  
  1378.     pthis = GetThis();
  1379.  
  1380.     // change button style
  1381.     SetArea(GetSprite(pthis),0);
  1382. }
  1383.  
  1384. /*
  1385.  *    Function        :  Button on mouse down callback
  1386.  */
  1387. func i32x ButtonDyn_OnMouseDown(i32x _iX,i32x _iY,i32x _iButton)
  1388. {
  1389.     var Gui_Component pthis;
  1390.     var Gui_Component parent;
  1391.  
  1392.     pthis = GetThis();
  1393.     parent = GetParent(pthis);
  1394.  
  1395.     if(_iButton == e_Gui_Mouse_Left_Button)
  1396.     {
  1397.         // change button style
  1398.         SetArea(GetSprite(pthis),2);
  1399.         // send mesg to parent
  1400.         parent<<ClickDown(pthis);
  1401.     }
  1402. }
  1403.  
  1404. /*
  1405.  *    Function        :  Button on mouse up callback
  1406.  */
  1407. func i32x ButtonDyn_OnMouseUp(i32x _iX,i32x _iY,i32x _iButton)
  1408. {
  1409.     var Gui_Component pthis;
  1410.     var Gui_Component parent;
  1411.  
  1412.     pthis = GetThis();
  1413.     parent = GetParent(pthis);
  1414.  
  1415.     if(_iButton == e_Gui_Mouse_Left_Button)
  1416.     {
  1417.         // send mesg to parent
  1418.         parent<<ClickUp(pthis);
  1419.     }
  1420. }
  1421.  
  1422. /*
  1423.  *    Function        : Button Mouse click callback
  1424.  *    Remarks            : Test left click
  1425.  *    Remarks            : Push click message to parent
  1426.  *    Message            : "MouseClick"
  1427.  */
  1428. func i32x ButtonDyn_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton)
  1429. {
  1430.     var Gui_Component pthis; 
  1431.     var Gui_Component parent;
  1432.  
  1433.     if(_iButton == e_Gui_Mouse_Left_Button)
  1434.     {
  1435.         pthis = GetThis();
  1436.     
  1437.         // change button style
  1438.         SetArea(GetSprite(pthis),3);
  1439.  
  1440.         parent = GetParent(pthis);
  1441.         parent<<Click(pthis);
  1442.         return 1;
  1443.     }
  1444.     else if(_iButton == e_Gui_Mouse_Right_Button)
  1445.     {
  1446.         pthis = GetThis();
  1447.         parent = GetParent(pthis);
  1448.         parent<<RightClick(pthis);
  1449.         return 1;
  1450.     }
  1451.     else if(_iButton == e_Gui_Mouse_Middle_Button)
  1452.     {
  1453.         pthis = GetThis();
  1454.         parent = GetParent(pthis);
  1455.         parent<<MiddleClick(pthis);
  1456.         return 1;
  1457.     }
  1458.     return 0;
  1459. }
  1460.  
  1461. func i32x TextRadioButton_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton)
  1462. {
  1463.     var Gui_dtRadioButton pdtRadio;
  1464.     var Gui_Component pthis; 
  1465.     var Gui_Component parent;
  1466.     if(_iButton == e_Gui_Mouse_Left_Button)
  1467.     {
  1468.         pthis = GetThis();
  1469.         parent = GetParent(pthis);
  1470.         
  1471.         pdtRadio = GetData(pthis);
  1472.         if(pdtRadio.bChecked==false)
  1473.         {
  1474.             TextRadioButton_OnQuietCheck(pdtRadio.iValue);
  1475.             parent<<RadioCheck(pthis,pdtRadio.iValue);
  1476.         }
  1477.         parent<<Click(pthis);
  1478.         return 1;
  1479.     }
  1480.     else if(_iButton == e_Gui_Mouse_Right_Button)
  1481.     {
  1482.         pthis = GetThis();
  1483.         parent = GetParent(pthis);
  1484.         parent<<RightClick(pthis);
  1485.         return 1;
  1486.     }
  1487.     else if(_iButton == e_Gui_Mouse_Middle_Button)
  1488.     {
  1489.         pthis = GetThis();
  1490.         parent = GetParent(pthis);
  1491.         parent<<MiddleClick(pthis);
  1492.         return 1;
  1493.     }
  1494.     return 0;
  1495. }
  1496. func void TextRadioButton_OnQuietCheck(i32x _iValue)
  1497. {
  1498.     var Gui_dtRadioButton pdtRadio;
  1499.     var Gui_Component pthis; 
  1500.     
  1501.     pthis = GetThis();
  1502.     pdtRadio = GetData(pthis);
  1503.  
  1504.     if(pdtRadio.iValue == _iValue)
  1505.     {
  1506.         pdtRadio.bChecked = true;
  1507.         SetColor(pthis,cEBColor);
  1508.     }
  1509.     else
  1510.     {
  1511.         pdtRadio.bChecked = false;
  1512.         SetColor(pthis,cWhite);
  1513.     }
  1514. }
  1515.  
  1516. func Gui_Component NewTextRadioButton(Menu_Material _pFont,szx _szTxt,i32x _iValue)
  1517. {
  1518.     var Gui_dtRadioButton pdtRadio;
  1519.     var Gui_Component container;
  1520.  
  1521.     // Create container with button interface
  1522.     container = NewCaption(_pFont,_szTxt);
  1523.     SetShadingMode(GetSprite(container),DLC_GouraudMode_ModulateDiffuse,DLC_GouraudMode_Decal);
  1524.  
  1525.     // Affect data pointer
  1526.     pdtRadio = new Gui_dtRadioButton;
  1527.     pdtRadio.bChecked = false;
  1528.     pdtRadio.iValue = _iValue;
  1529.  
  1530.     // Change interface to radio button interface
  1531.     SetInterface(container,Gui_iTextRadioButton);
  1532.     SetData(container,pdtRadio);
  1533.  
  1534.     return container;
  1535. }
  1536.  
  1537. /*
  1538.  *    Function        : CM2 In Race Button click callback
  1539.  *    Remarks            : Simply transfer message to parent
  1540.  *    Message            : "Click"
  1541.  */
  1542. func void CM2InRaceButton_OnClick(Gui_Component _pClicked)
  1543. {
  1544.     var Gui_Component parent,pthis; 
  1545.     var Gui_dtCM2InRaceButton pdtData;
  1546.  
  1547.     pthis = GetThis();
  1548.     pdtData = GetData(pthis);
  1549.     parent = GetParent(pthis);
  1550.  
  1551.     // change button style
  1552.     if(pdtData.bChecked)
  1553.     {
  1554.         SetArea(GetSprite(pdtData.gcRightButton),0);
  1555.         SetArea(GetSprite(pdtData.gcCenterButton),0);
  1556.         SetArea(GetSprite(pdtData.gcLeftButton),0);
  1557.         SetColor(pdtData.gcText, MakeARGB(255, 255, 67, 0));
  1558.         pdtData.bChecked=0;
  1559.         
  1560.         parent<<Uncheck(pthis);
  1561.     }
  1562.     else
  1563.     {
  1564.         SetArea(GetSprite(pdtData.gcRightButton),2);
  1565.         SetArea(GetSprite(pdtData.gcCenterButton),2);
  1566.         SetArea(GetSprite(pdtData.gcLeftButton),2);
  1567.         SetColor(pdtData.gcText, MakeARGB(255, 255, 67, 0));
  1568.         pdtData.bChecked=1;
  1569.  
  1570.         parent<<Click(pthis);
  1571.     }
  1572. }
  1573.  
  1574. /*
  1575.  *    Function        : Composite Button enter callback
  1576.  */
  1577. func i32x CM2InRaceButton_OnMouseEnter(i32x _iX,i32x _iY)
  1578. {
  1579.     var Gui_Component pthis; 
  1580.     var Gui_dtCM2InRaceButton pdtData;
  1581.  
  1582.     pthis = GetThis();
  1583.     pdtData = GetData(pthis);
  1584.  
  1585.     // change button style
  1586.     if(!pdtData.bChecked)
  1587.     {
  1588.         SetArea(GetSprite(pdtData.gcRightButton),1);
  1589.         SetArea(GetSprite(pdtData.gcCenterButton),1);
  1590.         SetArea(GetSprite(pdtData.gcLeftButton),1);
  1591.         SetColor(pdtData.gcText, MakeARGB(255, 255, 67, 0));
  1592.     }
  1593.  
  1594.     //Contextual Help
  1595.     if(strlen(pdtData.szContextualCaption)>=1)
  1596.     {
  1597.         g_gcManager<<MoveHint(_iX,_iY);
  1598.         g_gcManager<<ShowHint(pdtData.szContextualCaption);
  1599.         g_cCurrentHelpComponent=GetThis();
  1600.     }
  1601.     return 1;
  1602. }
  1603.  
  1604. /*
  1605.  *    Function        : Composite Button leave callback
  1606.  */
  1607. func i32x CM2InRaceButton_OnMouseLeave(i32x _iX,i32x _iY)
  1608. {
  1609.     var Gui_Component pthis; 
  1610.     var Gui_dtCM2InRaceButton pdtData;
  1611.  
  1612.     pthis = GetThis();
  1613.     pdtData = GetData(pthis);
  1614.  
  1615.     // change button style
  1616.     if(!pdtData.bChecked)
  1617.     {
  1618.         SetArea(GetSprite(pdtData.gcRightButton),0);
  1619.         SetArea(GetSprite(pdtData.gcCenterButton),0);
  1620.         SetArea(GetSprite(pdtData.gcLeftButton),0);
  1621.         SetColor(pdtData.gcText, MakeARGB(255, 255, 255, 255));
  1622.     }
  1623.  
  1624.     //Contextual Help
  1625.     if(strlen(pdtData.szContextualCaption)>=1)
  1626.     {
  1627.         if(g_cCurrentHelpComponent==GetThis())
  1628.         {
  1629.             g_gcManager<<HideHint();
  1630.             g_cCurrentHelpComponent=NULL;
  1631.         }
  1632.     }
  1633.     return 1;
  1634. }
  1635.  
  1636. /*
  1637.  *    Function        :  Button leave callback
  1638.  */
  1639. func i32x CM2InRaceButton_OnUncheck(Gui_Component _pSender)
  1640. {
  1641.     var Gui_Component pthis; 
  1642.     var Gui_dtCM2InRaceButton pdtData;
  1643.  
  1644.     pthis = GetThis();
  1645.     pdtData = GetData(pthis);
  1646.  
  1647.     // change button style
  1648.     pdtData.bChecked=0;
  1649.     pthis<<MouseLeave(0,0);
  1650. }
  1651.  
  1652. /*
  1653.  *    Function        :  Button caption
  1654.  */
  1655. func i32x CM2InRaceButton_OnCaption(szx _sxCaption)
  1656. {
  1657.     var Gui_Component pthis; 
  1658.     var Gui_dtCM2InRaceButton pdtData;
  1659.  
  1660.     pthis = GetThis();
  1661.     pdtData = GetData(pthis);
  1662.  
  1663.     // change button caption
  1664.     pdtData.gcText<<Caption(_sxCaption);
  1665. }
  1666.  
  1667. /*
  1668.  *    Function        : Composite Button on mouse down callback
  1669.  */
  1670. func i32x CM2InRaceButton_OnMouseDown(i32x _iX,i32x _iY,i32x _iButton)
  1671. {
  1672.     var Gui_Component pthis; 
  1673.     var Gui_dtCM2InRaceButton pdtData;
  1674.  
  1675.     pthis = GetThis();
  1676.     pdtData = GetData(pthis);
  1677.  
  1678.     // change button style
  1679.     if(!pdtData.bChecked)
  1680.     {
  1681.         SetArea(GetSprite(pdtData.gcRightButton),2);
  1682.         SetArea(GetSprite(pdtData.gcCenterButton),2);
  1683.         SetArea(GetSprite(pdtData.gcLeftButton),2);
  1684.         SetColor(pdtData.gcText, MakeARGB(255, 255, 67, 0));
  1685.     }
  1686.     else
  1687.     {
  1688.         SetArea(GetSprite(pdtData.gcRightButton),0);
  1689.         SetArea(GetSprite(pdtData.gcCenterButton),0);
  1690.         SetArea(GetSprite(pdtData.gcLeftButton),0);
  1691.         SetColor(pdtData.gcText, MakeARGB(255, 255, 67, 0));
  1692.     }
  1693. }
  1694.  
  1695. /*
  1696.  *    Function        : Button enter callback
  1697.  */
  1698. func i32x CM2BmpButton_OnMouseEnter(i32x _iX,i32x _iY)
  1699. {
  1700.     var Gui_Component pthis; 
  1701.     var Gui_dtCM2BmpButton pdtData;
  1702.  
  1703.     pthis = GetThis();
  1704.     pdtData = GetData(pthis);
  1705.  
  1706.     // change button style
  1707.     if(!pdtData.bChecked)
  1708.         SetArea(GetSprite(pthis),pdtData.iIndex+pdtData.iOffset);
  1709.  
  1710.     //Contextual Help
  1711.     if(strlen(pdtData.szContextualCaption)>=1)
  1712.     {
  1713.         g_gcManager<<MoveHint(_iX,_iY);
  1714.         g_gcManager<<ShowHint(pdtData.szContextualCaption);
  1715.         g_cCurrentHelpComponent=GetThis();
  1716.     }
  1717.     return 1;
  1718. }
  1719.  
  1720. /*
  1721.  *    Function        :  Button leave callback
  1722.  */
  1723. func i32x CM2BmpButton_OnMouseLeave(i32x _iX,i32x _iY)
  1724. {
  1725.     var Gui_Component pthis; 
  1726.     var Gui_dtCM2BmpButton pdtData;
  1727.  
  1728.     pthis = GetThis();
  1729.     pdtData = GetData(pthis);
  1730.  
  1731.     // change button style
  1732.     if(!pdtData.bChecked)
  1733.         SetArea(GetSprite(pthis),pdtData.iIndex);
  1734.  
  1735.     //Contextual Help
  1736.     if(strlen(pdtData.szContextualCaption)>=1)
  1737.     {
  1738.         if(g_cCurrentHelpComponent==GetThis())
  1739.         {
  1740.             g_gcManager<<HideHint();
  1741.             g_cCurrentHelpComponent=NULL;
  1742.         }
  1743.     }
  1744.     return 1;
  1745. }
  1746.  
  1747. /*
  1748.  *    Function        :  Button leave callback
  1749.  */
  1750. func i32x CM2BmpButton_OnUncheck(Gui_Component _pSender)
  1751. {
  1752.     var Gui_Component pthis; 
  1753.     var Gui_dtCM2BmpButton pdtButton;
  1754.  
  1755.     pthis = GetThis();
  1756.     pdtButton = GetData(pthis);
  1757.  
  1758.     // change button style
  1759.     pdtButton.bChecked=0;
  1760.     pthis<<MouseLeave(0,0);
  1761. }
  1762.  
  1763. /*
  1764.  *    Function        :  Button on mouse down callback
  1765.  */
  1766. func i32x CM2BmpButton_OnMouseDown(i32x _iX,i32x _iY,i32x _iButton)
  1767. {
  1768.     var Gui_Component pthis; 
  1769.     var Gui_dtCM2BmpButton pdtButton;
  1770.  
  1771.     pthis = GetThis();
  1772.     pdtButton = GetData(pthis);
  1773.  
  1774.     // change button style
  1775.     if(!pdtButton.bChecked)
  1776.         SetArea(GetSprite(pthis),pdtButton.iIndex+2*pdtButton.iOffset);
  1777.     else
  1778.         SetArea(GetSprite(pthis),pdtButton.iIndex);
  1779. }
  1780.  
  1781. /*
  1782.  *    Function        : Button Mouse click callback
  1783.  *    Remarks            : Test left click
  1784.  *    Remarks            : Push click message to parent
  1785.  *    Message            : "MouseClick"
  1786.  */
  1787. func void CM2BmpButton_OnMouseClick(i32x _iX,i32x _iY,i32x _iButton)
  1788. {
  1789.     var Gui_Component pthis; 
  1790.     var Gui_Component parent;
  1791.     var Gui_dtCM2BmpButton pdtButton;
  1792.  
  1793.     pthis = GetThis();
  1794.     parent = GetParent(pthis);
  1795.     pdtButton = GetData(pthis);
  1796.  
  1797.     // change button style
  1798.     if(pdtButton.bChecked)
  1799.     {
  1800.         SetArea(GetSprite(pthis),pdtButton.iIndex);
  1801.         pdtButton.bChecked=0;
  1802.         parent<<Uncheck(pthis);
  1803.     }
  1804.     else
  1805.     {
  1806.         SetArea(GetSprite(pthis),pdtButton.iIndex+2*pdtButton.iOffset);
  1807.         pdtButton.bChecked=1;
  1808.         parent<<Click(pthis);
  1809.     }
  1810. }
  1811.  
  1812. /*
  1813.  *    Function        : Button check callback
  1814.  *    Message            : "Check"
  1815.  */
  1816. func i32x CM2BmpButton_OnCheck(Gui_Component _pSender)
  1817. {
  1818.     var Gui_Component pthis; 
  1819.     var Gui_Component parent;
  1820.     var Gui_dtCM2BmpButton pdtButton;
  1821.  
  1822.     pthis = GetThis();
  1823.     parent = GetParent(pthis);
  1824.     pdtButton = GetData(pthis);
  1825.  
  1826.     // change button style
  1827.     if(!pdtButton.bChecked)
  1828.     {
  1829.         SetArea(GetSprite(pthis),pdtButton.iIndex+2*pdtButton.iOffset);
  1830.         pdtButton.bChecked=1;
  1831.         parent<<Click(pthis);
  1832.     }
  1833.     return 1;
  1834. }
  1835.